﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using SLWebApp.ServiceReference_HB;

namespace SLWebApp.ChildWindows
{
    public partial class ChildWindow_VoyageAmount : ChildWindow
    {
        //服务
        ServiceReference_HB.ServiceForSLClient clientService = new ServiceReference_HB.ServiceForSLClient();
        ObservableCollection<ServiceReference_HB.ST_Container_Sizes> mlist_Con_Size = null;//所有箱尺寸。
        ObservableCollection<ServiceReference_HB.ST_Container_Status> mlist_Con_Status = null;// 所有箱形。
        ObservableCollection<ServiceReference_HB.ST_Dangerous_Cargo_Codes> mlist_Dang_Codes = null;//所有危类等级。
        ObservableCollection<ServiceReference_HB.UM_Ref_Code> mlist_OVLMTCD = null;// 所有超限类别。
        ObservableCollection<ServiceReference_HB.UM_Voyage_Amounts> mlist_CTNAmount = null;//所有集装箱的箱量.
        ObservableCollection<ServiceReference_HB.UM_Ref_Code> mlistRef_Code = null;//所有大类小类。
        ObservableCollection<ServiceReference_HB.ST_VOYAGE_CARGO_AMOUNTS> mlist_Cargo_Amount = null;//所有散货箱的箱量。

        List<bool> listProgressBar = new List<bool>();

        /// <summary>
        /// 航次号
        /// </summary>
        string m_VOY_ID = string.Empty;

        /// <summary>
        /// 用户ID。
        /// </summary>
        int m_User_ID = 0;

        /// <summary>
        /// 进出口标志.
        /// </summary>
        string m_IEflg = string.Empty;

        /// <summary>
        /// 船期ID。
        /// </summary>
        string m_SCD_ID = string.Empty;
        /// <summary>
        ///  新增修改事件。
        /// </summary>
        public event MouseButtonEventHandler OnAdd_ModifyEvent;

        public ChildWindow_VoyageAmount(string voy_id, int user_id, string scd_id, string ieflg)
        {
            InitializeComponent();
            m_VOY_ID = voy_id;
            m_User_ID = user_id;
            m_SCD_ID = scd_id;
            m_IEflg = ieflg;
        }

        #region ////初始化
        //初始化
        private void ChildWindow_Loaded(object sender, RoutedEventArgs e)
        {
            progressbar.IsBusy = true;
            //箱尺寸
            clientService.GetSTContainerSizesAsync();
            clientService.GetSTContainerSizesCompleted -= new EventHandler<ServiceReference_HB.GetSTContainerSizesCompletedEventArgs>(clientService_GetSTContainerSizesCompleted);
            clientService.GetSTContainerSizesCompleted += new EventHandler<ServiceReference_HB.GetSTContainerSizesCompletedEventArgs>(clientService_GetSTContainerSizesCompleted);
            //箱状态
            clientService.GetSTContainerStatusAsync(" sts_iefg in('" + m_IEflg + "','Y') ", null);
            clientService.GetSTContainerStatusCompleted -= new EventHandler<ServiceReference_HB.GetSTContainerStatusCompletedEventArgs>(clientService_GetSTContainerStatusCompleted);
            clientService.GetSTContainerStatusCompleted += new EventHandler<ServiceReference_HB.GetSTContainerStatusCompletedEventArgs>(clientService_GetSTContainerStatusCompleted);
            //危类等级
            clientService.GetSTDangerousCargoCodesAsync();
            clientService.GetSTDangerousCargoCodesCompleted -= new EventHandler<ServiceReference_HB.GetSTDangerousCargoCodesCompletedEventArgs>(clientService_GetSTDangerousCargoCodesCompleted);
            clientService.GetSTDangerousCargoCodesCompleted += new EventHandler<ServiceReference_HB.GetSTDangerousCargoCodesCompletedEventArgs>(clientService_GetSTDangerousCargoCodesCompleted);
            //超限
            clientService.GetRefCodeAsync("rv_domain='OVLMTCD' ", string.Empty);
            clientService.GetRefCodeCompleted -= new EventHandler<ServiceReference_HB.GetRefCodeCompletedEventArgs>(clientService_GetRefCodeCompleted);
            clientService.GetRefCodeCompleted += new EventHandler<ServiceReference_HB.GetRefCodeCompletedEventArgs>(clientService_GetRefCodeCompleted);
            //集装箱箱量
            clientService.GetVoyageAmounts_CTNAmountAsync(" va.vat_voy_id= " + m_VOY_ID);
            clientService.GetVoyageAmounts_CTNAmountCompleted -= new EventHandler<GetVoyageAmounts_CTNAmountCompletedEventArgs>(clientService_GetVoyageAmounts_CTNAmountCompleted);
            clientService.GetVoyageAmounts_CTNAmountCompleted += new EventHandler<GetVoyageAmounts_CTNAmountCompletedEventArgs>(clientService_GetVoyageAmounts_CTNAmountCompleted);
            //所有类别
            clientService.GetUmRefCodeTreeViewAsync("rv_domain = 'GOODSTYPECD'  and rv_edicode is not null ", string.Empty);
            clientService.GetUmRefCodeTreeViewCompleted -= new EventHandler<GetUmRefCodeTreeViewCompletedEventArgs>(clientService_GetUmRefCodeTreeViewCompleted);
            clientService.GetUmRefCodeTreeViewCompleted += new EventHandler<GetUmRefCodeTreeViewCompletedEventArgs>(clientService_GetUmRefCodeTreeViewCompleted);

            //散货箱
            clientService.GetStVoyageCargoAmountsAsync(" VAG_VOY_ID= " + m_VOY_ID, string.Empty);
            clientService.GetStVoyageCargoAmountsCompleted -= new EventHandler<GetStVoyageCargoAmountsCompletedEventArgs>(clientService_GetStVoyageCargoAmountsCompleted);
            clientService.GetStVoyageCargoAmountsCompleted += new EventHandler<GetStVoyageCargoAmountsCompletedEventArgs>(clientService_GetStVoyageCargoAmountsCompleted);
        }

        //散货箱完成事件。
        void clientService_GetStVoyageCargoAmountsCompleted(object sender, GetStVoyageCargoAmountsCompletedEventArgs e)
        {
            SetProgressBar_True(true);
            mlist_Cargo_Amount = e.Result as ObservableCollection<ServiceReference_HB.ST_VOYAGE_CARGO_AMOUNTS>;
            dataGridBlukBox.ItemsSource = mlist_Cargo_Amount;
        }
        //所有类别的完成事件。
        void clientService_GetUmRefCodeTreeViewCompleted(object sender, GetUmRefCodeTreeViewCompletedEventArgs e)
        {
            SetProgressBar_True(true);
            mlistRef_Code = e.Result as ObservableCollection<ServiceReference_HB.UM_Ref_Code>;
            AddTreeNode("0", null);
        }

        // 集装箱箱量
        void clientService_GetVoyageAmounts_CTNAmountCompleted(object sender, GetVoyageAmounts_CTNAmountCompletedEventArgs e)
        {
            SetProgressBar_True(true);
            mlist_CTNAmount = e.Result as ObservableCollection<ServiceReference_HB.UM_Voyage_Amounts>;
            dataGrid_CTNAmount.ItemsSource = mlist_CTNAmount;

        }
        //超限完成事件
        void clientService_GetRefCodeCompleted(object sender, ServiceReference_HB.GetRefCodeCompletedEventArgs e)
        {
            SetProgressBar_True(true);
            mlist_OVLMTCD = e.Result as ObservableCollection<ServiceReference_HB.UM_Ref_Code>;
            comboxBoxOVLMTCD.ItemsSource = mlist_OVLMTCD;
        }
        //危类等级完成事件
        void clientService_GetSTDangerousCargoCodesCompleted(object sender, ServiceReference_HB.GetSTDangerousCargoCodesCompletedEventArgs e)
        {
            SetProgressBar_True(true);
            mlist_Dang_Codes = e.Result as ObservableCollection<ServiceReference_HB.ST_Dangerous_Cargo_Codes>;
            comboxBoxLevel.ItemsSource = mlist_Dang_Codes;
        }
        //箱状态完成事件
        void clientService_GetSTContainerStatusCompleted(object sender, ServiceReference_HB.GetSTContainerStatusCompletedEventArgs e)
        {
            SetProgressBar_True(true);
            mlist_Con_Status = e.Result as ObservableCollection<ServiceReference_HB.ST_Container_Status>;
            this.comboxBoxStyle.ItemsSource = mlist_Con_Status;
        }
        //箱尺寸完成事件。
        void clientService_GetSTContainerSizesCompleted(object sender, ServiceReference_HB.GetSTContainerSizesCompletedEventArgs e)
        {
            SetProgressBar_True(true);
            mlist_Con_Size = e.Result as ObservableCollection<ServiceReference_HB.ST_Container_Sizes>;
            this.comboxBoxSize.ItemsSource = mlist_Con_Size;
        }
        #endregion

        #region //点击事件
        //窗休关闭事件。
        private void ChildWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            progressbar.IsBusy = false;
        }

        private void btnSave_Container_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("确认保存？", "提示", MessageBoxButton.OKCancel);
            if (result.ToString() == "Cancel")
            {
                return;
            }
            string CSZ_CSIZECD = string.Empty;//箱尺寸。
            string STS_CSTATUSCD = string.Empty;//箱状态。
            string DTP_DNGGCD = string.Empty;//危类等级。
            string VAT_OVLMTCD = string.Empty;//超限

            string VAT_EFFG = string.Empty;//空重标志.

            if (comBoxEFfg.SelectionBoxItem != null)
            {
                VAT_EFFG = comBoxEFfg.SelectionBoxItem.ToString();
            }

            ST_Container_Sizes mCon_Size = comboxBoxSize.SelectedItem as ST_Container_Sizes;
            if (mCon_Size != null) CSZ_CSIZECD = mCon_Size.CSZ_CSIZECD;

            UM_Ref_Code mOvlmtcd = comboxBoxOVLMTCD.SelectedItem as UM_Ref_Code;
            if (mOvlmtcd != null) VAT_OVLMTCD = mOvlmtcd.RV_LOW_VALUE;

            ST_Dangerous_Cargo_Codes mDang_Code = comboxBoxLevel.SelectedItem as ST_Dangerous_Cargo_Codes;
            if (mDang_Code != null) DTP_DNGGCD = mDang_Code.DTP_DNGGCD;

            ST_Container_Status mCont_Status = comboxBoxStyle.SelectedItem as ST_Container_Status;
            if (mCont_Status != null) STS_CSTATUSCD = mCont_Status.STS_CSTATUSCD;

            string freeze = "N";
            if (rbtnY.IsChecked.Value)
            {
                freeze = "Y";
            }
            // if (ISAddAmount != null && ISAddAmount)
            clientService.InsertUpdateProcessCTNAmountAsync(1, m_VOY_ID, CSZ_CSIZECD, STS_CSTATUSCD,
                DTP_DNGGCD, VAT_OVLMTCD, freeze, this.txtContainerAmount.Text, m_User_ID.ToString(), VAT_EFFG, m_SCD_ID, string.Empty);
            //else
            //    clientService.InsertUpdateProcessCTNAmountAsync(2, m_VOY_ID, mCon_Size.CSZ_CSIZECD, mCont_Status.STS_CSTATUSCD,
            //    mDang_Code.DTP_DNGGCD, mOvlmtcd.RV_LOW_VALUE, freeze, this.txtContainerAmount.Text, m_User_ID.ToString(), string.Empty, string.Empty);
            clientService.InsertUpdateProcessCTNAmountCompleted -= new EventHandler<InsertUpdateProcessCTNAmountCompletedEventArgs>(clientService_InsertUpdateProcessCTNAmountCompleted);
            clientService.InsertUpdateProcessCTNAmountCompleted += new EventHandler<InsertUpdateProcessCTNAmountCompletedEventArgs>(clientService_InsertUpdateProcessCTNAmountCompleted);
        }
        //集装箱，新增完成事件。
        void clientService_InsertUpdateProcessCTNAmountCompleted(object sender, InsertUpdateProcessCTNAmountCompletedEventArgs e)
        {
            string str = e.Result;
            if (str.Substring(0, 1) == "1")
            {
                MessageBox.Show(str.Substring(2, str.Length - 2));
                clientService.GetVoyageAmounts_CTNAmountAsync(" va.vat_voy_id= " + m_VOY_ID);
                OnAdd_ModifyEvent(sender, null);//触发事件，更新主页航次箱量数据。
            }
            else
            {
                MessageBox.Show(e.Result.ToString());
            }
        }

        //集装箱，删除
        List<UM_Voyage_Amounts> mGridSelect = new List<UM_Voyage_Amounts>();
        private void btnContainer_Del_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //数据库删除。
            mGridSelect.Clear();
            ObservableCollection<string> mlist_CTN = new ObservableCollection<string>();
            foreach (var item in dataGrid_CTNAmount.SelectedItems)
            {
                UM_Voyage_Amounts mAmount = item as UM_Voyage_Amounts;
                mGridSelect.Add(mAmount);
                mlist_CTN.Add(mAmount.VAT_ID.ToString());
            }

            clientService.DeleteStVoyageAmountsAsync(mlist_CTN);
            clientService.DeleteStVoyageAmountsCompleted -= new EventHandler<DeleteStVoyageAmountsCompletedEventArgs>(clientService_DeleteStVoyageAmountsCompleted);
            clientService.DeleteStVoyageAmountsCompleted += new EventHandler<DeleteStVoyageAmountsCompletedEventArgs>(clientService_DeleteStVoyageAmountsCompleted);
        }
        //删除完成事件.
        void clientService_DeleteStVoyageAmountsCompleted(object sender, DeleteStVoyageAmountsCompletedEventArgs e)
        {
            if (e.Result)//返回TRUE表示数据库删除成功。
            {
                foreach (UM_Voyage_Amounts item in mGridSelect)
                {
                    this.mlist_CTNAmount.Remove(item);
                }
            }
        }

        //集装箱行选择事件.
        private void dataGrid_CTNAmount_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UM_Voyage_Amounts umAmount = dataGrid_CTNAmount.SelectedItem as UM_Voyage_Amounts;
            if (umAmount == null)
                return;

            var csizedd = (from aa in mlist_Con_Size
                           where aa.CSZ_CSIZECD == umAmount.VAT_CSZ_CSIZECD
                           select aa).ToList();
            if (csizedd != null && csizedd.Count > 0)
            {
                comboxBoxSize.SelectedItem = csizedd[0];
            }

            var ovlmtcd = (from aa in mlist_OVLMTCD
                           where aa.RV_LOW_VALUE == umAmount.VAT_OVLMTCD
                           select aa).ToList();// as UM_Ref_Code;
            if (ovlmtcd != null && ovlmtcd.Count > 0)
            {
                comboxBoxOVLMTCD.SelectedItem = ovlmtcd[0];
            }

            var dnggcd = (from aa in mlist_Dang_Codes
                          where aa.DTP_DNGGCD == umAmount.VAT_DNGFG
                          select aa).ToList();
            if (dnggcd != null && dnggcd.Count > 0)
            {
                comboxBoxLevel.SelectedItem = dnggcd[0];
            }

            var status = (from aa in mlist_Con_Status
                          where aa.STS_CSTATUSCD == umAmount.VAT_STS_CSTATUSCD
                          select aa).ToList();
            if (status != null && status.Count > 0)
            {
                comboxBoxStyle.SelectedItem = status[0];
            }
            string freeze = umAmount.VAT_RFFG;
            if (freeze.ToLower() == "y")
            {
                rbtnN.IsChecked = false;
                rbtnY.IsChecked = true;
            }
            else
            {
                rbtnN.IsChecked = true;
                rbtnY.IsChecked = false;
            }
            if (!string.IsNullOrEmpty(umAmount.VAT_EFFG))
            {
                if (umAmount.VAT_EFFG.ToUpper() == "E")
                {
                    this.comBoxEFfg.SelectedIndex = 0;
                }
                if (umAmount.VAT_EFFG.ToUpper() == "F")
                {
                    this.comBoxEFfg.SelectedIndex = 1;
                }
            }
            txtContainerAmount.Text = umAmount.VAT_AMOUNT == null ? "" : umAmount.VAT_AMOUNT.ToString();
        }

        //修改保存
        private void btnContainer_Modefy_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            UM_Voyage_Amounts mAmount = dataGrid_CTNAmount.SelectedItem as UM_Voyage_Amounts;
            if (mAmount == null) return;

            MessageBoxResult result = MessageBox.Show("确认修改？", "提示", MessageBoxButton.OKCancel);
            if (result.ToString() == "Cancel")
            {
                return;
            }

            string CSZ_CSIZECD = string.Empty;//箱尺寸。
            string STS_CSTATUSCD = string.Empty;//箱状态。
            string DTP_DNGGCD = string.Empty;//危类等级。
            string VAT_OVLMTCD = string.Empty;//超限
            string VAT_EFFG = string.Empty;//空重标志.

            if (comBoxEFfg.SelectionBoxItem != null)
            {
                VAT_EFFG = comBoxEFfg.SelectionBoxItem.ToString();
            }

            ST_Container_Sizes mCon_Size = comboxBoxSize.SelectedItem as ST_Container_Sizes;
            if (mCon_Size != null) CSZ_CSIZECD = mCon_Size.CSZ_CSIZECD;

            UM_Ref_Code mOvlmtcd = comboxBoxOVLMTCD.SelectedItem as UM_Ref_Code;
            if (mOvlmtcd != null) VAT_OVLMTCD = mOvlmtcd.RV_LOW_VALUE;

            ST_Dangerous_Cargo_Codes mDang_Code = comboxBoxLevel.SelectedItem as ST_Dangerous_Cargo_Codes;
            if (mDang_Code != null) DTP_DNGGCD = mDang_Code.DTP_DNGGCD;

            ST_Container_Status mCont_Status = comboxBoxStyle.SelectedItem as ST_Container_Status;
            if (mCont_Status != null) STS_CSTATUSCD = mCont_Status.STS_CSTATUSCD;

            string freeze = "N";
            if (rbtnY.IsChecked.Value)
            {
                freeze = "Y";
            }

            clientService.InsertUpdateProcessCTNAmountAsync(2, m_VOY_ID, CSZ_CSIZECD, STS_CSTATUSCD,
                DTP_DNGGCD, VAT_OVLMTCD, freeze, this.txtContainerAmount.Text, m_User_ID.ToString(), VAT_EFFG, m_SCD_ID, mAmount.VAT_ID.ToString());
            clientService.InsertUpdateProcessCTNAmountCompleted -= new EventHandler<InsertUpdateProcessCTNAmountCompletedEventArgs>(clientService_InsertUpdateProcessCTNAmountCompleted);
            clientService.InsertUpdateProcessCTNAmountCompleted += new EventHandler<InsertUpdateProcessCTNAmountCompletedEventArgs>(clientService_InsertUpdateProcessCTNAmountCompleted);
        }

        #endregion

        //处理进度条
        private void SetProgressBar_True(bool isComplete)
        {
            //共有4个初始化数据请求
            if (listProgressBar.Count == 6)
            {
                progressbar.IsBusy = false;
            }
            else
            {
                listProgressBar.Add(isComplete);
            }

        }

        //树状图选择事件。
        private void treeType_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            TreeViewItem item = e.NewValue as TreeViewItem;
            UM_Ref_Code fi = item.DataContext as UM_Ref_Code;

            this.txtStyle.Text = fi.RV_MEANING;
            this.txtStyle.Tag = fi.RV_LOW_VALUE;
        }

        //向树里增加节点.
        private void AddTreeNode(string parentID, TreeViewItem treeViewItem)
        {
            List<UM_Ref_Code> result = (from table in mlistRef_Code
                                        where table.RV_EDICODE == parentID
                                        select table).ToList();

            if (result.Count > 0)
            {
                foreach (UM_Ref_Code item in result)
                {
                    TreeViewItem objTreeNode = new TreeViewItem();
                    objTreeNode.Header = item.RV_MEANING;
                    objTreeNode.DataContext = item;

                    //此样式将会添加的所有叶子结点上
                    //objTreeNode.ItemContainerStyle = this.Resources["RedItemStyle"] as Style;

                    //添加根节点
                    if (treeViewItem == null)
                    {
                        treeType.Items.Add(objTreeNode);
                    }
                    else
                    {
                        treeViewItem.Items.Add(objTreeNode);
                    }
                    AddTreeNode(item.RV_LOW_VALUE, objTreeNode);
                }
            }
        }

        #region 散货箱量
        //新增
        private void btnBulk_Save_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //this.txtStyle
            //txtCount 件数
            //txtWeight
            //txtVolumn

            clientService.InsertUpdateProcessCargoAmountAsync(1, m_VOY_ID, null, this.txtStyle.Tag.ToString(), txtCount.Text, txtWeight.Text, txtVolumn.Text, null, m_User_ID.ToString(), m_SCD_ID);
            clientService.InsertUpdateProcessCargoAmountCompleted -= new EventHandler<InsertUpdateProcessCargoAmountCompletedEventArgs>(clientService_InsertUpdateProcessCargoAmountCompleted);
            clientService.InsertUpdateProcessCargoAmountCompleted += new EventHandler<InsertUpdateProcessCargoAmountCompletedEventArgs>(clientService_InsertUpdateProcessCargoAmountCompleted);
        }
        //新增\修改完成事件。
        void clientService_InsertUpdateProcessCargoAmountCompleted(object sender, InsertUpdateProcessCargoAmountCompletedEventArgs e)
        {
            MessageBox.Show(e.Result);
            clientService.GetStVoyageCargoAmountsAsync(" VAG_VOY_ID= " + m_VOY_ID, string.Empty);
        }

        #endregion
        //修改
        private void btnBulk_Modefy_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ST_VOYAGE_CARGO_AMOUNTS mCargo = dataGridBlukBox.SelectedItem as ST_VOYAGE_CARGO_AMOUNTS;
            clientService.InsertUpdateProcessCargoAmountAsync(2, m_VOY_ID, mCargo.VAG_ID.ToString(), this.txtStyle.Tag.ToString(), txtCount.Text, txtWeight.Text, txtVolumn.Text, null, m_User_ID.ToString(), m_SCD_ID);
            clientService.InsertUpdateProcessCargoAmountCompleted -= new EventHandler<InsertUpdateProcessCargoAmountCompletedEventArgs>(clientService_InsertUpdateProcessCargoAmountCompleted);
            clientService.InsertUpdateProcessCargoAmountCompleted += new EventHandler<InsertUpdateProcessCargoAmountCompletedEventArgs>(clientService_InsertUpdateProcessCargoAmountCompleted);
        }
        //删除
        List<ST_VOYAGE_CARGO_AMOUNTS> mlistCargo = new List<ST_VOYAGE_CARGO_AMOUNTS>();
        private void btnBulk_Del_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // dataGridBlukBox.SelectedItems
            //数据库删除。
            ObservableCollection<string> mlist_CTN = new ObservableCollection<string>();
            mlistCargo.Clear();
            foreach (var item in dataGridBlukBox.SelectedItems)
            {
                ST_VOYAGE_CARGO_AMOUNTS mAmount = item as ST_VOYAGE_CARGO_AMOUNTS;
                mlistCargo.Add(mAmount);
                mlist_CTN.Add(mAmount.VAG_ID.ToString());
            }
            clientService.DeleteProcessCargomountAsync(mlist_CTN);
            clientService.DeleteProcessCargomountCompleted -= new EventHandler<DeleteProcessCargomountCompletedEventArgs>(clientService_DeleteProcessCargomountCompleted);
            clientService.DeleteProcessCargomountCompleted += new EventHandler<DeleteProcessCargomountCompletedEventArgs>(clientService_DeleteProcessCargomountCompleted);
        }

        void clientService_DeleteProcessCargomountCompleted(object sender, DeleteProcessCargomountCompletedEventArgs e)
        {
            if (e.Result)//返回TRUE表示数据库删除成功。
            {
                foreach (ST_VOYAGE_CARGO_AMOUNTS item in mlistCargo)
                {
                    this.mlist_Cargo_Amount.Remove(item);
                }
            }
        }

        //散货箱量修改时绑定事件。
        private void dataGridBlukBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ST_VOYAGE_CARGO_AMOUNTS mAmount = dataGridBlukBox.SelectedItem as ST_VOYAGE_CARGO_AMOUNTS;
            if (mAmount == null) return;
            //this.txtStyle.Tag.ToString(), txtCount.Text, txtWeight.Text, txtVolumn.Text
            this.txtStyle.Text = mAmount.RV_MEANING;
            this.txtStyle.Tag = mAmount.VAG_GTYPECD;
            txtCount.Text = mAmount.VAG_PKG.ToString();
            txtVolumn.Text = mAmount.VAG_VOL.ToString();
            txtWeight.Text = mAmount.VAG_TON.ToString();

        }


    }//end class
}